//
//  DBJNavigationController.m
//  DBJ
//
//  Created by 花化华 on 2016/11/12.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "DBJNavigationController.h"

@interface DBJNavigationController ()

@end

@implementation DBJNavigationController

/**
 *  让状态栏变亮
 */
- (UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
}

/**
 *  初始化ui
 */
- (void)setupUI{
    
    //让导航条不透明
    self.navigationBar.translucent = NO;
    
    //苹果自带就给你根线，而且这根线是UIImageView,默认希望导航栏跟界面有一个很明显的分界线
    //去掉导航条的分割线一定要有以下两句话才有用
    self.navigationBar.shadowImage = [[UIImage alloc]init];
    [self.navigationBar setBackgroundImage:[[UIImage alloc]init] forBarMetrics:UIBarMetricsDefault];
    
    //设置背景色 78	194	156
    self.navigationBar.barTintColor = DBJColor;
    
    //设置字体颜色
    [self.navigationBar setTitleTextAttributes:@{
                                                 NSForegroundColorAttributeName:[UIColor whiteColor]
                                                 }];
    //设置navigationItem的BarButtonItem
    [self.navigationBar setTintColor:[UIColor whiteColor]];
    
}

/**
 * 跳转其它页面时隐藏tabbar,并且设置返回item的文字为返回
*/
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
        //设置返回item文字为返回
        viewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];
    }
    [super pushViewController:viewController animated:animated];
    
}

@end
